<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <!--weui.min.css-->
    <link rel="stylesheet" href="/static/index/css/page/base.css"/>
    <link rel="stylesheet" href="/static/index/css/page/font.css"/>
    <link rel="stylesheet" href="/static/index/jquery_weui/css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/lib/weui.min.css">
    <!--jquery-weui.min.css-->
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/css/jquery-weui.min.css">
    <link rel="stylesheet" href="/static/index/css/page/release.css" />
    <!--表情选择器css-->
    <link href="/static/index/css/page/webiaoqing.css" rel="stylesheet" type="text/css">
	<!--表情选择器js-->
	<script src="/static/index/jquery_weui/js/jquery_min.js" ></script>
	<script src="/static/index/jquery_weui/js/webiaoqin.js" ></script>
    <style>
    	
    	.pageControl{
    		min-height: 100%;
    		position: relative;
    	}
    	.answer-input {
    		position: fixed;
    		bottom: 0;
    		left: 0;
    		right: 0;
    		background: #fff;
    	}
    	.answer-input a{
    		padding: .2rem .6rem;
    		border-radius: 5px;
    		background: #F7F7F7;
    		border: 1px solid #EEEEEE;
    	}
    	#page_emotion_show{
    		padding: 0;
    		border-radius:0;
    		background: #F7F7F7;
    		border:none;
    		position: absolute;
    		top: 7px;
    		left: 10px;
    	}
    	
    	.answer-input .weui-input{
    		border: 1px solid #F7F7F7;
    		background: #f7f7f7;
    		padding: .2rem;
    		width: 85%;
    	}
    	.main{
    		margin-bottom: 2.6rem;
    	}
    	/*图片处理css*/
    	.list2 .swiper-slide>a{
    		overflow: hidden;
    		position: relative;
    	}
    	.list2 .swiper-slide>a img{
    		
    		position: absolute;
    		left: 50%;
    		top: 50%;
    	}
    	.weui-cell2{
    		padding:0.4rem;
    	}
    	
    	#biaoqin{
    		
    	}
    	.answer-input .weui-input {
 
		}
		#form_article img{
			vertical-align: middle;
		}
		#form_article{
			background: transparent;
			position: relative;
			z-index: 1000;
			height: auto;
			margin-left: 1.5rem;
		}
		#content{
			position: absolute;
			left: 15px;
			right: 0;
			bottom: 0;
			top: 7px;
			margin-left: 1.2rem;
			width: 64%;
		}

		.card-message .card-title p img{
			width: 20px;
			height: 20px;
		}
		#page_emotion{
			overflow: hidden;
			width: 100%;
			
		}
		.type{
			position:absolute;
			height: .90rem;
			line-height: .90rem;
			border-radius: 20px;right: .80rem;
			top: .50rem;
			padding:0.05rem .6rem;
			color:#ffffff;
			z-index:999;
		}
		.weui-photo-browser-modal{
			z-index: 100000000;
		}
		.cl-47c {
			color: #47CDDF;
		}

		.comment-main,.content-width{
			width:125%;
		}
		.comment-name{
			color:#09d1c1;
		}
		.comment-time{
			float:right;
			margin-top:.2rem;
		}
		.gift-font{
			color:#ff7300;
		}
    </style>
</head>
<body>
<div class="pageControl card bg-f5">
    <div class="zhe"></div>
    <!--主体-->
    <div class="main">

        <div class="bg-di"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">活动详情</h1>
			<p class="bg-ff7 type">
				<span>{if $info['pay_type'] eq 1}买单{else}AA制{/if}</span>
				<input type="hidden" id="xid" value="{$id}"/>
			</p>
        </div>
        <div class="card  pl-add">
            <div class="weui-cell bg-fff">
                <div class="weui-label viewImage">
                	{if $user['img']}
                    <a href="javascript:;"><img data-img="0" class="viewPhone" src="{$user['img']}" alt="{$user['img']}"/></a>
                    {else}
                    <a href="javascript:;"><img src="/static/index/img/head.png" alt=""/></a>
                    {/if}
                </div>
                <div class="weui-cell__bd">
                    <p>{$user['name']}</p>
                    <div class="list-age">
                        <p class="">
                            <img src="{if $user['sex'] eq 1}/static/index/images/n1.png{else}/static/index/images/n0.png{/if}" alt=""/>
                            <span  class="cl-47c">{$user['age']}岁</span>
                        </p>
                        <p class="">
                            {if $user['is_rz'] eq 1}<img src="/static/index/images/x0.png" alt=""/>{/if}
                            <span   class="cl-fc8">{if $user['is_rz'] eq 1}已认证{elseif $user['is_rz'] eq 2}&nbsp;&nbsp;&nbsp;待审核{else}&nbsp;&nbsp;&nbsp;未认证{/if}</span>
                            <input type="hidden" id="xid" value="{$id}"/>
                        </p>
                    </div>
                </div>
				{if $uid neq $user_id}
                <div class="weui-cell__ft card-btn">
                    <a id="guzhu" class="bg-26c guan">
						{if $info_gz eq 0}
						<img src="/static/index/img/hx.png" alt=""/>
						{else}
						<img src="/static/index/img/g2.png" alt=""/>
						{/if}
                        <span class="cl-f">关注此团</span>

					</a>
                    {if $is_apply gt 0}
                    	<a class="bg-ff7 apply">
	                        <img src="/static/index/img/sq.png" alt=""/>
	                        <span class="cl-f">申请中.....</span>
	                    </a>
                    {else}
                    	{if $success_apply gt 0}
                    		{if $quit_count gt 0}
		                    	<a class="bg-ff7 apply" style="background: #ccc;">
			                        <img src="/static/index/img/sq.png" alt=""/>
			                        <span class="cl-f">退出此团</span>
			                    </a>
		                    {else}
			                    <a id="quit" class="bg-ff7 apply">
			                        <img src="/static/index/img/sq.png" alt=""/>
			                        <span class="cl-f">退出此团</span>
			                        <!--活动发布者id-->
			                        <input type="hidden" id="uid" value="{$uid}"/>
			                    </a>
		                    {/if}
	                    {else}
		                    <a id="apply" class="bg-ff7 apply">
		                        <img src="/static/index/img/sq.png" alt=""/>
		                        <span class="cl-f">申请加入</span>
		                        <!--活动发布者id-->
		                        <input type="hidden" id="uid" value="{$uid}"/>
		                    </a>
		                {/if}
                    {/if}
                </div>
                {/if}
            </div>
            <div class="card-list personal-list">
	                <div class="list2 t0">
	                    <p class="list2-a">{$info.content}</p>
	                    <!--<p class="list2-b">-- <span>阿尔伯特·爱因斯坦</span></p>-->
	                    <div class="swiper-container">
	                        <div class="swiper-wrapper pic1">
                        	<?php $ssh = explode("|",$info['photo']);?>
                            {foreach name="ssh" item="photo"}
	                            <div class="swiper-slide">
									 <a class="item"><img src="{$photo}" alt=""/></a>
	                            </div>
                            {/foreach}
                        </div>
	                        <div class="pic-count"><?php echo count($ssh)?>张</div>
	                    </div>

	                    <div class="weui-cell1">
	                        <div class="weui-cell__bd"></div>
	                        <div class="weui-cell__ft"></div>
	                    </div>
	                    <div class="weui-cell1">
	                        <div class="weui-cell__bd">
	                            <img src="/static/index/img/x5.png" alt=""/>
	                            <span class="cl-9999">参团费用：{$info.deposit}元</span>
	                        </div>
	                        <div class="weui-cell__ft">
	                            <img src="/static/index/img/x2.png" alt=""/>
	                            <span>{$info.count}</span>
	                        </div>
	                        <div class="weui-cell__ft">
	                            <img src="/static/index/img/x3.png" alt=""/>
	                            <span>{$comment_count}</span>
	                        </div>

	                    </div>
	                <div class="weui-cell card_cell">
		                <div class="weui-cell__bd">
		                    <p class="fs07 cl-9999">{if $info.only_rz eq 1}该发布人只允许进行了实名认证的人参加{/if}</p>
		                </div>
		                <div class="weui-cell__ft">
		                    <p class="cl-9999 fs07">已有 <span>{$offered_count}</span> 人参加</p>
		                </div>
		            </div>
            </div>
            <!--<input type="text" id="gift" placeholder="请输入送花数量" value=""><input type="button" id="give" value="送花">-->
				<div class="card-message" data-id="{$vo.id}">
					{foreach name="comment" item="vo"}
						<!--评论-->
						{if $vo.type eq 1}
						<div class="weui-cell wind">
							<div class="weui-cell__bd">
								<div class="pic">
									<a href="javascript:;"><img src="{$vo.img}" alt=/></a>
								</div>
								<div class="card-title">
									<p class="comment-main">
										<span class="comment-name">{$vo.name}</span>
										<img src="/static/index/images/n{$vo.sex}.png" alt="">
										<span class="cl-47c">{$vo.age}岁</span>
										<span class="comment-time">{$vo.create_time}</span>
									</p>
									<p class="cl-3333 fs07 title-date content-width get-answer__id">
										{$vo.content}
										<input type="hidden" value="{$vo.comment_id}"/>
									</p>
								</div>
							</div>
						</div>

						<!--回复-->
						{elseif $vo.type eq 2}
						<div class="weui-cell wind">
							<div class="weui-cell__bd">
								<div class="pic">
									<a href="javascript:;"><img src="{$vo.img}" alt=/></a>
								</div>
								<div class="card-title">
									<p class="comment-main">
										<span class="comment-name">{$vo.name}</span>
										<img src="/static/index/images/n{$vo.sex}.png" alt="">
										<span class="cl-47c">{$vo.age}岁</span>
										<span class="comment-time">{$vo.create_time}</span>
									</p>
									<p class="title-date content-width get-answer__id">
										<span class="content-name">回复   {$vo.answer_name}：</span>{$vo.content}
										<input type="hidden" value="{$vo.comment_id}"/>
									</p>
								</div>
							</div>
						</div>
						{else}
						<!--送礼-->
						<div class="weui-cell wind">
							<div class="weui-cell__bd">
								<div class="card-title">
									<p id="" class="comment-main">
										<span class="gift-font">{$vo.name}   送出{$vo.num}个  {$vo.gift_type}</span>
									</p>
								</div>
							</div>
						</div>
					{/if}
					{/foreach}
				</div>

        </div>

    </div>

	<div class="page_emotion box_swipe" id="page_emotion">
		<dl id="list_emotion" class="list_emotion pt_10"></dl>
		<dt><ol id="nav_emotion" class="nav_emotion"></ol></dt>
	</div>


    <div class="answer-input weui-cell answerBtn">

    	<div class="weui-cell__bd">
    		<a href="" id="page_emotion_show"><img src="/static/index/images/arclist/0.gif" alt="" /></a>
    		<article id="form_article" class="weui-input" contenteditable="true" onkeydown="myInput.listen(this, event);"></article>
    		<input class="weui-input" placeholder="评论" id='content' type="contenteditable"></input>
    	</div>
    	<div class="weui-cell__ft">
    		<a  id="pl" href="">发送</a>
    	</div>
    </div>
</div>
	<!--<div class="pl">
		<div class="weui-tabbar">
			<a href="javascript:;" class="weui-tabbar__item givePresent">
				<div class="weui-tabbar__icon">
					<img src="/static/index/images/tl1.png" alt="">
				</div>
				<p class="weui-tabbar__label cl-47c fs065">送礼</p>
			</a>
			<a href="" class="weui-tabbar__item">
				<div class="weui-tabbar__icon">
					<img src="/static/index/images/tl2.png" alt="">
				</div>
				<p class="weui-tabbar__label cl-47c fs065">评论</p>
			</a>
		</div>
	</div>-->
	<!--<div class="givePresent-nav">
		<a href="" class="layer"></a>
		<div class="givePresent-bd">
			<div class="swiper-container1">
				<div class="swiper-wrapper">
					<div class="swiper-slide">
						<a href="javascript:;" class="">
							<img src="/static/index/images/present2.png" alt="">
							<div><span class="cl-3333 name">棒棒糖</span></div>
							<div class="cl-3333"><span class="cl-d69 count">1</span>拾友币</div>
						</a>
						<a href="javascript:;">
							<img src="/static/index/images/present5.png" alt="">
							<div><span class="cl-3333 name">杜蕾斯</span></div>
							<div class="cl-3333"><span class="cl-d69 count">2</span>拾友币</div>
						</a>
						<a href="javascript:;">
							<img src="/static/index/images/present9.png" alt="">
							<div><span class="cl-3333 name">元宝</span></div>
							<div class="cl-3333"><span class="cl-d69 count">3</span>拾友币</div>
						</a>
						<a href="javascript:;">
							<img src="/static/index/images/present3.png" alt="">
							<div><span class="cl-3333 name">宝箱</span></div>
							<div class="cl-3333"><span class="cl-d69 count">4</span>拾友币</div>
						</a>
						<a href="javascript:;">
							<img src="/static/index/images/present4.png" alt="">
							<div><span class="cl-3333 name">蛋糕</span></div>
							<div class="cl-3333"><span class="cl-d69 count">5</span>拾友币</div>
						</a>
						<a href="javascript:;" class="">
							<img src="/static/index/images/present1.png" alt="">
							<div><span class="cl-3333 name">钻戒</span></div>
							<div class="cl-3333"><span class="cl-d69 count">6</span>拾友币</div>
						</a>
					</div>
					<div class="swiper-slide">
						<a href="javascript:;" class="">
							<img src="/static/index/images/present8.png" alt="">
							<div><span class="cl-3333 name">挖掘机</span></div>
							<div class="cl-3333"><span class="cl-d69 count">7</span>拾友币</div>
						</a>
						<a href="javascript:;">
							<img src="/static/index/images/present6.png" alt="">
							<div><span class="cl-3333 name">法拉利</span></div>
							<div class="cl-3333"><span class="cl-d69 count">8</span>拾友币</div>
						</a>
						<a href="javascript:;">
							<img src="/static/index/images/present10.png" alt="">
							<div><span class="cl-3333 name">游艇</span></div>
							<div class="cl-3333"><span class="cl-d69 count">9</span>拾友币</div>
						</a>
						<a href="javascript:;" class="">
							<img src="/static/index/images/present7.png" alt="">
							<div><span class="cl-3333 name">飞机</span></div>
							<div class="cl-3333"><span class="cl-d69 count">10</span>拾友币</div>
						</a>
					</div>
				</div>
				<div class="swiper-pagination"></div>
			</div>
			<div class="givePresent-bottom">
				<p class="buyButton mtop01">
					<button disabled="disabled" class="subtract">-</button>
					<span>1</span>
					<button class="add">+</button>
				</p>
				<a href="javascript:;" class="givePresent-btn">发送</a>
			</div>
		</div>
	</div>-->
<!-- jquery-2.1.4 -->
<script type="text/javascript" src="/static/index/jquery_weui/lib/jquery-2.1.4.js"></script>
<!-- jquery-weui.min.js -->
<script type="text/javascript" src="/static/index/jquery_weui/js/jquery-weui.min.js"></script>
<script src="/static/index/jquery_weui/js/swiper.min.js"></script>
<!--送花-->
<script>

    $('.viewImage').on('click','img.viewPhone',function (e) {
        e.preventDefault();
        var imgmain=[];
        var tt=$(this).parents('.viewImage').find('img.viewPhone');
        var countActive=$(this).attr('data-img');
        countActive=parseFloat(countActive);
        var count=tt.length;
        for (var i=0;i<count;i++){
            imgmain.push(tt[i].alt);
        }
        console.log(imgmain);
        var pb1 = $.photoBrowser({
            items:imgmain,
            onSlideChange: function(index) {
                console.log(index);
                console.log()
            },
            onOpen: function() {

            },
            onClose: function() {

            },
            initIndex:countActive
        });
        pb1.open();

        $(`.weui-photo-browser-modal.weui-photo-browser-modal-visible .swiper-wrapper .swiper-slide:nth-of-type(${countActive+1})`).addClass('swiper-slide-active')
    });

	$('#give').on('click',function () {
        var flower = $("#gift").val();
        var uid = {$uid};//活动发布者id
        $.post(
            "/index/index/give_gift",
            {flower: flower,uid: uid},
            function(data){
                obj = jQuery.parseJSON(data);
				alert(obj.msg);
				$('#gift').val('');
            }
        ),'json'
    })
</script>
<script>
	$(function(){
		var winHeight = $(window).height();   
		$(window).resize(function(){
		   var thisHeight=$(this).height();
		    if(winHeight - thisHeight >50){
		    	var contentHeight=parseFloat($('.card-list.personal-list ').css('height'));
				contentTop=$('.answerBtn').offset().top+contentHeight
				$('html, body').animate({  
		                    scrollTop: contentTop  
		                }, 1000);
		        //窗口发生改变(大),故此时键盘弹出
		         //当软键盘弹出，在这里面操作
		    }else{
		    	
		        //窗口发生改变(小),故此时键盘收起
		        //当软键盘收起，在此处操作
		    }
		});
		var contentHeight=parseFloat($('.answerBtn.weui-cell ').css('height'));
		console.log(contentHeight);
		contentTop=$('.answerBtn').offset().top+contentHeight+20
		$("#content").focus(function(){
			$('html, body').animate({  
                    scrollTop: contentTop  
                }, 1000);
		})
		$(".page_emotion").hide()
		$("#page_emotion_show").click(function(e){
			e.preventDefault();
			var pageDisply=$(".page_emotion").css('display');
			console.log(pageDisply)
			if(pageDisply=='none'){
				$(".page_emotion").show();
			}else if(pageDisply=='block'){
				$(".page_emotion").hide()
			}
//			滚动
			$('html, body').animate({  
                    scrollTop: $('.answerBtn').offset().top  
                }, 1000);
			
		})
		$('#list_emotion').on('click','span',function(){
			$("#content").css('display','none');
			var answerHeight=parseFloat($(".answer-input.weui-cell").css('height'))+20;
			$('.page_emotion.box_swipe').css('margin-bottom',answerHeight);
			$('html, body').animate({  
                    scrollTop: $('.answerBtn').offset().top  
                }, 1000);
		})
		$(document).keyup(function(event){ 
			if($('#form_article').html()!==''){
			$("#content").css('display','none');
	 		}else{
	 		$("#content").css('display','block');
	 		}
	 		var answerHeight=parseFloat($(".answer-input.weui-cell").css('height'))+20;
	
			$('.page_emotion.box_swipe').css('margin-bottom',answerHeight)
		})

	
	
	
$("#content").val('');
});
	$('#biaoqin').click(function(){
		$("#page_emotion").css('display','');
	})

	var answer_id;//被评论人的id
	var user_id = {$user_id};//登录用户（评论者）

	$('.get-answer__id').on('click',function () {
		id = $(this).find('input[type="hidden"]').val();//被评论人的id
		answer_id = id;
		name = $(this).prev().find(".comment-name").html();//被评论人的name
		if(user_id != id){
            $('#content').attr('placeholder','回复   '+name);
        }
    })
	$(function(){
		
		//		图片处理
		$('.personal-list .swiper-slide>a img').each(function(){
			
			var imgWidth=-parseFloat($(this).css('width'))/2;
			var imgHeight=-parseFloat($(this).css('height'))/2;
			/*console.log(imgWidth)
			console.log(imgHeight)*/
			
			var imgWidth1=parseFloat($(this).css('width'));
			var imgHeight1=parseFloat($(this).css('height'));
			if(imgWidth1>=imgHeight1){
				$(this).css({
					height:'100%',
					width:'auto'
				})
			$(this).css('top','0')
			$(this).css('margin-left',imgWidth)
			}else if(imgWidth1<imgHeight1){
				$(this).css({
					height:'auto',
					width:'100%'
				})
				$(this).css('margin-top',imgHeight)
				$(this).css('margin-left',imgWidth)
			}
		})
		
		
		var swiperWidth=$('.list .swiper-slide').width();
		/*console.log(swiperWidth)*/
		$('.list .swiper-slide').css('height',swiperWidth)
		$('.list .swiper-slide>a img').css('min-height',swiperWidth)
		
		$('.noteMemo').each(function(){
		var ttCount=$(this).find('.index-btn1 a.note-list').length;
		var listCount=$(this).find('.index-btn1 a').length;
		if(listCount>4){
			for(var i=1;i<=ttCount;i++){
				if(i>3){
					$(this).find(`.index-btn1 a.note-list:nth-of-type(${i})`).css('display','none')
				}
			}
			$(this).find('.note-more').css('display','inline-block')
		}else if(listCount<=4){
			$(this).find('.note-more').css('display','none')
		}
	    /*console.log(listCount)*/
		})
		
		var swiperWidth=$('.card-list .swiper-slide').width();
		/*console.log(swiperWidth)*/
		$('.card-list .swiper-slide').css('height',swiperWidth)
	})
	
	$("#pl").click(function(e){
		e.preventDefault();
		var placeholder = $('#content').attr('placeholder');
		//判断用户是否完善个人信息
		$.post(
				"/index/index/person_message",
			    function(data){
//			    	console.log(data);return;
			    	if(data == 1){
	    		//		console.log(single)
						if(placeholder == '评论'){
							var content = $("#form_article").html();
							var comment_id = {$user_id};//评论人id（当前登录用户id）
							var active_id = {$id};//活动id
					        $.post(
								"/index/index/detail_pl",
								{content: content,comment_id: comment_id,active_id: active_id},
							    function(data){
							    	if(data.code == -1){
							    		alert(data.msg);
							    	}else if(data.code == 1){
							    		img = data.msg.img;
							    		name = data.msg.name;
							    		age = data.msg.age;
							    		sex = data.msg.sex;
							    		comment_ids = data.msg.comment_id;
							    		content = data.msg.content;
							    		create_time = data.msg.create_time;

							    		str = "<div class='weui-cell wind'><div class='weui-cell__bd'><div class='pic'><a href='javascript:;'><img src='"+img+"' alt='/'></a></div><div class='card-title'><p id='' class='comment-main'><span class='comment-name'>"+name+"</span><img src='/static/index/images/n"+sex+".png' alt=''><span class='cl-47c'>"+age+"岁</span><span class='comment-time'>"+create_time+"</span></p><p class='cl-3333 fs07 title-date content-width get-answer__id'>"+content+"<input type='hidden' value="+comment_ids+"/></p></div></div></div>";
							    		$('.card-message').append(str);
							    	}
//							    	$('#form_article').html('');
							    	$("#content").css('display','block')
						   		}
							),'json';
						}else{
							//回复
							var content = $("#form_article").html();//回复内容
							var active_id = {$id};//活动id
							$.post(
								"/index/index/add_answer",
								{content: content,answer_id: answer_id,active_id: active_id,comment_id:user_id},
							    function(data){
							    	if(data.code == -2){
							    		alert(data.msg);
                                    }else if(data.code == 1){
                                        name = data.msg.name;//评论者name
                                        img = data.msg.img;
                                        age = data.msg.age;
                                        sex = data.msg.sex;
                                        content = data.msg.content;
                                        create_time = data.msg.create_time;
                                        named = data.msg.named;//被评论者name
                                        id = data.msg.id;//被评论者id(放入隐藏域vlaue值中)

                                        str="<div class='weui-cell wind'><div class='weui-cell__bd'><div class='pic'><a href='javascript:;'><img src='"+img+"' alt='/'></a></div><div class='card-title'><p class='comment-main'><span class='comment-name'>"+name+"</span><img src='/static/index/images/n"+sex+".png' alt=''><span class='cl-47c'>"+age+"岁</span><span class='comment-time'>"+create_time+"</span></p><p class='title-date content-width get-answer__id'><span class='content-name'>回复   "+named+"：</span>"+content+"<input type='hidden' value='"+id+"'></p></div></div></div>";
                                        $('.card-message').append(str);
                                        $('#form_article').html('');
                                        $("#content").css('display','block');
                                    }

						   		}
							),'json';
						}
			    	}else if(data.code == -1){
			    		alert(data.msg);
			    		window.location.href="/index/personal/photo?id="+{$user_id};
			    	}else{
			    		alert(data.msg);
			    		pl_get_url = window.location.pathname;
			    		pl_get_data = window.location.search;
			    		url = pl_get_url+''+pl_get_data;
			    		window.location.href='/index/login/login_deng?url='+url;
			    	}
		   		}
			),'json';
			//			滚动
			$('html, body').animate({  
                    scrollTop: $('.answerBtn').offset().top  
                }, 1000);
	});
	/*$(".comment_content").click(function (){
		alert($(".comment_content").attr("id"));
	});*/
    var swiper = new Swiper('.swiper-container', {
        slidesPerView: 3,
        spaceBetween: 5
    });
    var listLength=$(".card-list").children().length;
    /*for(var i=0;i<listLength;i++){
        var slider_length=$(`.card-list .t${i} .swiper-wrapper`).children().length;
        $(`.card-list .t${i} .pic-count`).html(slider_length+"张")
    }*/
	    
	   
	//jquery获取url参数
	(function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
    })(jQuery);   
	
    
    $("#guzhu").click(function(){
        var id = $("#xid").val();//活动id
        var uid = $("#uid").val();//发起人id
        $.ajax({
            type:'post',
            url:'/index/index/dd',
            data:{uid:uid,id:id},
            success:function(data){
                if(data == "1") {
                    alert('关注成功');
                    $('#guzhu').find('img').attr('src','/static/index/img/g2.png');
                }else if(data =="-1"){
                    alert('您还未登录，请先登录！');
		    		id = $.getUrlParam('id');
		    		uid = $.getUrlParam('uid');
		    		window.location.href="/index/login/login_deng?id="+id+"&uid="+uid;
                }else if(data =="-2"){
                    alert("您已关注此活动");
                }else if(data =="0"){
                    alert("不能关注自己发布的活动");
                }
            }
	    })
	});
		
	
    
    $("#apply").click(function (){
         var uid = $("#uid").val();//发起人id
         var id = $("#xid").val();//活动id
         var deposit = {$info.deposit};

            $.post(
                "/index/index/addapply",
                {uid:uid,id:id,deposit:deposit},
                function(data){
                    obj = jQuery.parseJSON(data);
                    if(obj.code != -5){
                        if(data != -2){

                            if(data == -4){
                                alert('活动已开始，报名失败!');
                            }else{
                                if(window.confirm('申请活动需要参团费用'+deposit+'元，您确定要申请吗？')){
                                    if(data == "1"){
                                        $('.apply .cl-f').html('申请中...');
                                        alert('申请成功，请等待审核结果！');
                                    }else if(data == "-1"){
                                        alert('申请失败！');
                                    }else if(data == "-3"){
                                        alert("您的余额不足，申请失败！");
                                    }else if(data == "-6"){
                                        alert("该活动只限于已实名认证用户");
                                    }
                                }else{
                                    return false;
                                }
                            }
                        }else{
                            alert("您已申请该活动，请耐心等待审核结果！");
                        }
                    }else{
                        alert('您还未登录，请先登录！');
                        id = $.getUrlParam('id');
                        uid = $.getUrlParam('uid');
                        window.location.href="/index/login/login_deng?id="+id+"&uid="+uid;
                    }

                }
            );
    });


    /*点击发送按钮*/
    $(".givePresent-btn").on('click',function () {
        gift = $(".swiper-container1 a.active .count").html();
        gift_type = $(".swiper-container1 a.active .name").html();
        if(gift != 0){
            count = $('.buyButton').find("span").html();
            coins = gift*count;//赠送礼物所消耗拾友币
            var uid = {$uid};//活动发布者id
            var id = {$id};//活动id
            var user_id = {$user_id};//活动发布者id
            if(uid != user_id){
                $.post(
                    "/index/index/send_gift",
                    {coins: coins,uid: uid,count:count,gift_type:gift_type,id:id},
                    function(data){
                        if(data.code == -5){
                            alert('您还未登录，请先登录！');
                            id = $.getUrlParam('id');
                            uid = $.getUrlParam('uid');
                            window.location.href="/index/login/login_deng?id="+id+"&uid="+uid;
						}else{
                            if(data.code == 1){
                                name = data.msg.name;
                                count = data.msg.count;
                                gift_type = data.msg.gift_type;
								console.log(data.msg);
                                str = "<div class='weui-cell wind'><div class='weui-cell__bd'><div class='card-title'><p class='comment-main'><span class='gift-font'>"+name+"   送出"+count+"个  "+gift_type+"</span></p></div></div></div>";
                                $('.card-message').append(str);
                            }else{
                                if (confirm(data.msg)) {
                                    window.location.href="/index/personal/coins_recharge";
                                }
                            }
                        }
                    }
                ),'json'
            }else{
                alert('送礼失败，不能给自己发布的活动送礼！');
            }
        }else{
            alert('请选择礼物类型！');
        }
    })
    
   /* 
    var res=prompt("请输入取消活动的原因","");
		if(res != null && res != ""){
			$.post(
				"/index/personal/cancel",
				{active_id: active_id,reason: res},
				function(data){
					if(data == 1){
						alert('取消活动申请成功，请等待审核结果！');
						$('#active_cancel').css('display','none');
						$('#active_start').html('取消活动申请审核中...');
						$('#active_start').css('background','#ccc');
					}else{
						alert('取消活动申请失败，请稍后再试！')
					}
				}
			)
		}else{
			if(res != null){
				alert('请填写取消活动原因！');
			}
		}
    * */
	/*退出此团*/
	$('#quit').click(function(){
		user_id = {$user_id};//活动参与者
		active_id = {$id};//活动id
		
		var res=prompt("请输入退出此团的原因","");
		if(res != null && res != ""){
			$.post(
				"/index/index/quit_active",
				{user_id: user_id,active_id: active_id,reason: res},
				function(data){
					if(data == 1){
						alert('退出此团申请成功，请等待审核结果！');
						window.location.href="/index/index/detail?id="+active_id+"&uid="+{$uid};
					}else{
						alert('退出此团申请失败，请稍后再试！')
					}
				}
			)
		}else{
			if(res != null){
				alert('请填写退出此团原因！');
			}
		}
	});





    window.POP = {}

    ;(function(P){
        P.eventMap = {
            listen : {},
            on : function(type, fn){
                if(typeof type === 'string'){
                    if(!this.listen.hasOwnProperty(type)){
                        this.listen[type] = [];
                    }
                    if(typeof fn === 'function'){
                        return this.listen[type].push(fn);
                    }
                }
            },
            fire : function(type){
                if(typeof type === 'string'){
                    var _listenType = this.listen[type];
                    if(_listenType instanceof Array){
                        for (var i = 0; i < _listenType.length; i++) {
                            _listenType[i].apply(this,[].slice.call(arguments,1));
                        }
                    }
                }
            },
            remove : function(type){
                if(type instanceof Array){
                    var _type;
                    for (var i = 0; i < type.length; i++) {
                        if(type[i] && this.listen.hasOwnProperty(type[i])){
                            delete this.listen[type[i]];
                        }
                    }
                }else{
                    if(type && this.listen.hasOwnProperty(type)){
                        delete this.listen[type];
                    }
                }
            }
        }
    })(POP);

    ;(function(P, win, doc){
        var _layer = 2000;

        P.pic = function(obj,option){
            return new _t(obj,option);
        }

        var _t = function(){
            this.init.apply(this, arguments)
        }

        _t.prototype = {
            init : function(obj, option){
                this.$el = typeof obj === 'string' ? doc.querySelector(obj) : obj;
                var _imgSrc = '';
                var opt = {
                    dataSrc : 'data-src',
                    _imgSrc : _imgSrc,
                    item : 'li'
                }
                if(option && option instanceof Object){
                    for(var k in option){
                        opt[k] = option[k];
                    }
                }
                console.log(opt)
                this.opt = opt;
                this._index = this.opt.index;

                //创建弹出内容
                var _item = this.$el.querySelectorAll(this.opt.item);
                var _self = this;
                [].forEach.call(_item,function(item,i){
                    item.addEventListener('click',function(e){
                        e.preventDefault();
                        this._index = i;
                        this.createContent();
                        this.initPage(i);
                        this.init = null;
                    }.bind(_self),false);
                });

            },
            bindUI : function(){
                var _list = this._list;
                var _item = _list.querySelectorAll('span');
                var _self = this;
                this.isRun = false;

                _list.addEventListener('touchstart',this,false);
                _list.addEventListener('touchmove',this,false);
                _list.addEventListener('touchend',this,false);
                window.addEventListener('resize',this,false);

                this._wrap.addEventListener('click',function(e){
                    e.preventDefault();
                    POP.eventMap.fire('wrapClick');
                },true);
            },
            destroy : function(){

                var _list = this._list;
                this._wrap.classList.remove('isShow');
                this._wrap.addEventListener("webkitTransitionEnd",remove,false);
                this._wrap.addEventListener("transitionend",remove,false);

                function remove(){
                    this.parentNode && this.parentNode.removeChild(this);
                }

                POP.eventMap.remove('wrapClick');
                _list.removeEventListener('touchstart',this,false);
                _list.removeEventListener('touchmove',this,false);
                _list.removeEventListener('touchend',this,false);
            },
            handleEvent : function(e){
                var _type = e.type;
                switch (_type) {
                    case 'touchstart':
                        this.touchstart(e)
                        break;
                    case 'touchmove':
                        this.touchmove(e)
                        break;
                    case 'touchend':
                        this.touchend(e)
                        break;
                    case 'resize':
                        this.resize()
                        break;
                }
            },
            start : function(e){
                return {
                    _x : e.targetTouches[0].pageX,
                    _y : e.targetTouches[0].pageY
                }
            },
            touchstart : function(e){
                this.posX = this.start(e)._x;
                this.tranX = parseInt(this.getTransform(this._list)) || 0;
                this.offX = 0;
                this.startTime = new Date() * 1;
                this.isRun = true;
            },
            touchmove : function(e){
                if(this.isRun){
                    this.offX = this.start(e)._x - this.posX;
                    var _px = this.tranX + this.offX;
                    var _index = this._index;
                    if(_px > 8 || _px < -8){
                        e.preventDefault()
                    }
                    if(_index == 0 && this.offX > 0 || _index == this.len-1 && this.offX < 0){
                        _px = this.tranX + this.offX * 0.3
                    }

                    this.setTransform(_px,0);
                    this._px =  _px;
                }
            },
            touchend : function(e){
                if((Math.abs(this.offX) || 0) == 0) return;
                if(this.isRun){
                    var _endTime = new Date() * 1;
                    var _pw = this.getWin.w() / 6;
                    var _index = this._index;
                    var _len = this.len;
                    if(_endTime - this.startTime > 50 && Math.abs(this.offX) > _pw){
                        _index = this.offX > _pw ? (_index == 0 ? 0 : --_index) : (_index >= _len-1 ? _len -1 : ++_index);
                        this._index = _index;
                        this.goTransform(_index);
                    }else{
                        this.goTransform(_index);
                    }
                }
                this.isRun = false;
            },
            resize : function(){
                this.getWin.w();
                this.getWin.h();
                this.initPage(this._index);
                this.initStyle();
            },
            goTransform : function(n){
                var _w = -n * this.getWin.w();
                this.loadImg(n);
                this.pageCur.innerText = n+1;
                this.setTransform(_w);
            },
            loadImg : function(n){
                var _o = this._list.querySelectorAll('span')[n];
                var _img = _o.querySelector('img');
                var _dataSrc = 'data-src'
                if(_img.getAttribute(_dataSrc)){
                    _img.setAttribute('src',_img.getAttribute(_dataSrc));
                    _img.removeAttribute(_dataSrc);
                    _o.style.background = 'none';
                }
            },
            initPage : function(n){
                this.loadImg(n);
                this._list.style.webkitTransition = 'none';
                this._list.style.webkitTransform = 'translate3d('+-(n * this.getWin.w())+'px,0,0)';
            },
            setTransform : function(_x,ts){
                this._list.style.webkitTransition = ts == 0 ? 'none' : 'all .5s';
                this._list.style.webkitTransform = 'translate3d('+(_x ? _x : 0)+'px,0,0)';
            },
            getTransform : function(o){
                return win.getComputedStyle(o)['webkitTransform'].split(',')[4];
            },
            createContent : function(){
                _layer++;
                var _header = '<div class="pic_head">(<span class="pageCur">'+(this._index+1)+'</span>/<span class="pageSize">'+this.$el.querySelectorAll(this.opt.item).length+'</span>)</div>';
                var _content = '<div class="picContent">\
								<div class="picList"></div>\
							</div>';
                this.getElement('body').insertAdjacentHTML('beforeEnd','<div id="pic_wrap'+_layer+'" class="pic_wrap">'+_header + _content+'</div>');

                var _topHead = doc.querySelector('head');
                if(!_topHead.querySelector('#picStyle')){
                    var style ='<style id="picStyle">\
								.pic_wrap {position:fixed; left:0; top:0; width:100%; height:100%; z-index: 1000; opacity: 0; -webkit-transition:all .5s; transition:all .5s; }\
								.pic_head { width:100%; height:25px; line-height:25px; background:#000; text-align: center; color:#fff;}\
								.isShow { opacity: 1;}\
								.picContent {position:relative; width:100%; height:100%; background:#000; overflow: hidden;}\
								.picList {position: absolute; left:0; top:0; width:100%; height:100%;}\
								.picList .picItems {display: table-cell; vertical-align: middle; text-align: center; background:url('+this.opt._imgSrc+') no-repeat center center; background-size:16px 16px;}\
								.picList .picItems img {max-width: 100%; max-height: 100%; vertical-align: middle; }\
							</style>';
                    _topHead.insertAdjacentHTML('beforeEnd',style);
                }

                var _wrap = this.getElement('#pic_wrap'+_layer);
                this._head = _wrap.querySelector('.pic_head');
                this._list = _wrap.querySelector('.picList');
                this.pageCur = _wrap.querySelector('.pageCur');
                this._wrap = _wrap;
                this._wrap.classList.add('isShow');
                this.initPic();
                this.bindUI();

                POP.eventMap.on('wrapClick',function(){
                    this.destroy();
                }.bind(this));
            },
            initPic : function(){
                var _item = this.$el.querySelectorAll(this.opt.item);
                var _len = _item.length;
                if(_len){

                    var imgArr = [],_self = this;
                    [].forEach.call(_item,function(item,i){
                        if(item.getAttribute(_self.opt.dataSrc)){
                            imgArr.push({
                                loadShow : 0,
                                src : item.getAttribute(_self.opt.dataSrc)
                            });
                        }else if(item.querySelector('img')){
                            var _img = item.querySelector('img');
                            if(_img.getAttribute(_self.opt.dataSrc)){
                                imgArr.push({
                                    loadShow : 0,
                                    src : _img.getAttribute(_self.opt.dataSrc)
                                });
                            }else{
                                imgArr.push({
                                    loadShow : 1,
                                    src : _img.getAttribute('src')
                                });
                            }
                        }
                    });

                    var _html = '';
                    for (var i = 0; i < imgArr.length; i++) {
                        _html += '<span class="picItems"><img '+(imgArr[i].loadShow ? "src" : "data-src")+'="'+imgArr[i].src+'"></span>';
                    }

                    this.len = _len;
                    this._list.innerHTML = _html;

                    this.initStyle();

                }
            },
            //初始化dom
            initStyle : function(){
                var _item = this._list.querySelectorAll('.picItems');
                var win = this.getWin;
                var _w = _item.length * win.w();
                this._list.style.width = _w + 'px';
                for (var i = 0; i < _item.length; i++) {
                    _item[i].style.cssText = 'width:'+ win.w() +'px; height:'+ parseInt(win.h() - this._head.offsetHeight) +'px';
                }
            },
            getElement : function(o){
                return typeof o === 'string' ? doc.querySelector(o) : o;
            },
            getWin : {
                w : function(){
                    return win.innerWidth;
                },
                h : function() {
                    return win.innerHeight;
                }
            }
        }

    })(POP,window,document);


    POP.pic('.pic1',{item : 'a',dataSrc:'data-src'})


    $('.givePresent-nav').on('click','.swiper-slide a',function (e) {
        e.preventDefault();
        var that=$(this);
        that.parent().parent().find('a').siblings().removeClass('active');
        that.addClass('active');
    })
    //送礼数量减号
    $('.buyButton button.subtract').click(function () {
        var t=$(this).next().html();
        if(t>2){
            t-=1;
        }else if(t=2){
            t=1;
            $(this).attr('disabled','disabled')
        }
        $(this).next().html(t);
    })
    //送礼数量加号
    $('.buyButton button.add').click(function () {
        var t=parseFloat($(this).prev().html());
        t+=1;
        $(this).prev().prev().removeAttr('disabled','disabled')
        $(this).prev().html(t);
    })
    // 送礼切换
    $('.givePresent').click(function (e) {
        e.preventDefault();
        $('.givePresent-nav').css({
            top:0,
            bottom:0
        });
        $('.givePresent-bd').animate({
            bottom:'0'
        });
    });
    // 隐藏
    $('.layer').click(function (e) {
        e.preventDefault();
        $('.givePresent-bd').animate({
            bottom:'-50%'
        },function () {
            $('.givePresent-nav').css({
                top: '100%',
                bottom:'-100%'
            });
        });
    });
    $('.givePresent').click(function (e) {
        e.preventDefault();
        $('#ss').popup()
    });
    var swiper = new Swiper('.swiper-container1', {
        pagination: '.swiper-pagination',
        slidesPerView: 1,
        paginationClickable: true,
        spaceBetween: 5
    });
</script>
</body>
</html>

